using System.Collections.Generic;
using Castle.ActiveRecord;
using Cooking.Core.DataInterfaces;
using Cooking.Core.Model;
using NHibernate.Expression;

namespace Cooking.Data
{
    public class TipDao : DaoBase<Tip>, ITipDao
    {
        public IList<Tip> GetList()
        {
            return new List<Tip>(ActiveRecordMediator<Tip>.FindAll());
        }

        public Tip FindByName(string name)
        {
            DetachedCriteria dc = DetachedCriteria.For<Tip>().Add(Expression.Eq("Name", name));
            Tip tip = ActiveRecordMediator<Tip>.FindFirst(dc);

            return tip;
        }
    }
}